<template>
  <div class="common-table">
    <el-table :data="tableData" height="450px">
      <el-table-column
        show-overflow-tooltip
        v-for="item in tableLabel"
        :key="item.prop"
        :label="item.label"
        :width="item.width ? item.width : 125"
      >
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row[item.prop] }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="180">
        <template slot-scope="scope">
          <el-button size="mini" @click="headleEdit(scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="headleDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- <el-pagination
            class="pager"
            layout="perv,pager,next"
            :total="config.total"
            :current-page.sync="config.page"
            @curren-change="changePage"
            :page-size="20"
        ></el-pagination> -->
      <el-pagination
        class="pager"
        @size-change="handleSizeChange"
        @current-change="changePage"
        :current-page.sync="config.page"
        :page-size="20"
        layout="total, sizes, prev, pager, next, jumper"
        :total="config.total"
      >
      </el-pagination>
  </div>
</template>

<script>
export default {
  name: "CommonTable",
  props: {
    tableData: Array,
    tableLabel: Array,
    config: Object,
  },
  data() {
    return {};
  },
  methods: {
    headleEdit(row) {
      this.$emit("edit", row);
    },
    headleDelete(row) {
      console.log(row);
      this.$emit("del", row);
    },
    changePage(page) {
      this.$emit("changePage", page);
    },
    handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
  },
};
</script>

<style lang='less' scoped>
.common-table {
  height: calc(100%-62px);
  background-color: aliceblue;
  position: relative;
  .pager {
    position:relative;
    bottom: 0;
    right: 20px;
    display: flex;
    justify-content: center;
  }
}
</style>